package com.example.newsdaily.slice;

import com.example.newsdaily.LoginAbility;
import com.example.newsdaily.RegisterAbility;
import com.example.newsdaily.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;

public class LoginOrRegisterAbilitySlice extends AbilitySlice {

    Button login;
    Button register;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_LoginOrRegister);
        login=(Button)findComponentById(ResourceTable.Id_lor_lg);
        register=(Button)findComponentById(ResourceTable.Id_lor_rg);

        login.setClickedListener(component ->{
            Intent intent1=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withBundleName(getBundleName())
                    .withAbilityName(LoginAbility.class)
                    .build();
            intent1.setOperation(operation);
            startAbility(intent1);
        });

        register.setClickedListener(component ->{
            Intent intent1=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withBundleName(getBundleName())
                    .withAbilityName(RegisterAbility.class)
                    .build();
            intent1.setOperation(operation);
            startAbility(intent1);
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
